<template>

  <a-table :pagination="false" :columns="tableColumns" :data-source="tableData" :rowKey='record=>record.id'>
    <span slot="action" slot-scope="text, record">
          <a-button type="primary" @click="clickEditButton(record)">查看工单</a-button>
    </span>
  </a-table>

</template>

<script>

// 控制表头显示的内容
const columns = [
  {
    title:'Id',
    dataIndex: 'id',
    key: 'id',
  },
  {
    title:'工单名称',
    dataIndex: 'flowconf',
    key: 'flowconf',
  },
  {
    title:'创建者',
    dataIndex: 'create_user',
    key: 'create_user',
  },
  {
    title:'创建时间',
    dataIndex: 'create_ts',
    key: 'create_ts',
  },
  {
    title:'工单状态',
    dataIndex: 'order_status_name',
    key: 'order_status_name',
  },
  {
    title: '操作',
    key: 'action',
    scopedSlots: { customRender: 'action' },
  },
];

export default {
  data() {
    return {
      tableColumns: columns,  // 表头中绑定的数据
    };
  },
  props: ["tableData","visible"],
  methods:{

    // 点击编辑按钮时调用的事件
    clickEditButton(record){
      this.$router.push("/workorder/workorder/" + record.id)
    },

    // 点击删除按钮时调用的事件
    clickDeleteButton(id){
      const isDel = confirm('你确定要删除' + id)
      this.$emit('update:editData', {
        id: id,
      })
      if(isDel){
        this.$emit('requestDelete')
      }
    },

  }
};
</script>
